{/* LAYOUT模板 */}
<layout name="layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}
<js href="__PUBLIC__/js/admin/listTable.js"/>
<js href="__PUBLIC__/js/admin/js.util.js"/>
<css href="__PUBLIC__/css/admin/common.css"/>
<css href="__PUBLIC__/css/jquery-ui.css" />
<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
<js href="__PUBLIC__/js/core/plugins.js"/>
<js href="__JS__/core/jquery.form.js"/>
{/* import js,css */}
<!-- [position] -->
<include file="Template:position"/>
<!-- [position] -->
<!-- [气泡提示框插件HTML代码] -->
<include file="Core:QTip"/>
<!-- [气泡提示框插件HTML代码] -->
<div id="loading"class="hide"><!--Qloading:不能删除--></div>

<style>
.add-retail-table tr {height:40px;}
</style>
<div class="main-div">
	<form id="add-retail-form" method="post" action="__URL__/{$action}" name="theForm" enctype="multipart/form-data">
		<table cellspacing="1" cellpadding="3" width="100%" class="add-retail-table">
			<tr>
				<td class="label" align="right">代理商名称&nbsp;&nbsp;</td>
				<td>
					<input type="text" name="name" maxlength="60" size = "30" value="{$retail_info.name}" />&nbsp;&nbsp;<b style="color:red;">*</b>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">办公电话&nbsp;&nbsp;</td>
				<td>
					<input type="text" name="tel" maxlength="60" size = "30" value="{$retail_info.tel}" />&nbsp;&nbsp;<b style="color:red;">*</b>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">手机号码&nbsp;&nbsp;</td>
				<td>
					<input type="text" name="mobile_phone" maxlength="60" size = "30" value="{$retail_info.mobile_phone}" />&nbsp;&nbsp;<b style="color:red;">*</b>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					
					图片&nbsp;&nbsp;
				</td>
				<td>
					<if condition="$retail_info['thumb_img'] neq ''">
						<img src="__UPLOAD__/images/{$retail_info.thumb_img}" width="30px" height="30px"/>
					</if>
					<br/>
					<input type="file" name="orignal_img"  size="45">
					<br/>
					<br/>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('notice_cardfee');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					详细地址&nbsp;&nbsp;
				</td>
				<td>
					<div>
						<div>
							{$retail_info.province_name}(省) - {$retail_info.city_name}(市) - {$retail_info.district_name}(县/区) - {$retail_info.area} <a id="mod-retail-btn" style="color:red;cursor:pointer;">修改</a>
 						</div>
						<input type="hidden" name="country" value="1"/>
						<div class="address-wrap hide">
							<style>
								.area_wrap{list-style:none;}
								.area_wrap li{display:block;float:left;width:100px;height:30px;}
							</style>
							<ul class="area_wrap">
								<li>
									<select id="province" name="province"></select>
								</li>
								<li>
									<select id="city" name="city" style="display:none;"></select>
								</li>
								<li>
									<select id="district" name="district" style="display:none;"></select>
								</li>
								<div style="clear:both;"></div>
							</ul>						
							<div style="padding:10px;padding-left:0px;">
								<input type="text" name="area" style="width:250px;" value="{$retail_info.area}"/>
							</div>
						</div>
					</div>
				</td>
			</tr>			
			<tr>
				<td class="label" align="right">
					排序&nbsp;&nbsp;
				</td>
				<td>
					<input type="text" name="sort" value="{$retail_info.sort}">					
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('notice_cardfreemoney');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					简介&nbsp;&nbsp;
				</td>
				<td>
					<textarea style="width:250px;height:120px;" name="description">{$retail_info.description}</textarea>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>
				<input class="submit-btn" type="submit" value="确定" />
				<input type="reset" value="重置" />
				<input type="hidden" name="act" value="{$action}" />
				<input type="hidden" name="id" value="{$retail_info.id}" />
				<input type="hidden" name="original_img" value="{$retail.original_img}">
				</td>
			</tr>
		</table>
	</form>
</div>
<div>
	<a href="{:U('retail/retail_list')}" style="color:blue;">返回代理上列表</a>
</div>

<script language="JavaScript">
$(document).ready(function(){
	$('#add-retail-form').ajaxForm({
		//url: '',                 
		type: 'post',             
		dataType: 'json',        
		//clearForm: true,
		//resetForm: true,
		//timeout: 3000,		
		beforeSubmit:function(){/*提交前的回调函数*/
			var values = $('#add-retail-form').QVal();
			if(values.name == ''){
				$('#loading').QLoading({img:'sad',text:'代理商名称不能为空',time:1.5});
				return false;
			}
			if(values.area == ''){
				$('#loading').QLoading({img:'sad',text:'详细地址不能为空',time:1.5});
				return false;
			}
			/*if(values.city == null || values.district == null){
				$('#loading').QLoading({img:'sad',text:'地址填写不完整',time:1.5});
				return false;
			}*/
			$('#loading').QLoading({text:'提交中...',status:'open'});
			//return true;
		},
		success:function(msg){/*提交后的回调函数*/
			if(msg == 'yes'){
				$('#loading').QLoading({img:'happy',text:'添加成功',time:1.5});
			}
			else{
				$('#loading').QLoading({img:'sad',text:'添加失败',time:1.5});
			}
		}			
	}); 
	/*初始化省份*/
	$.ajax({
		url:'{:U('retail/get_region')}',
		type:'post',
		dataType:'json',
		data:{region_type:1},
		beforeSuccess:function(){},
		success:function(msg){
			$('#province').html('').html(msg);
		}
	});
	/*绑定事件*/
	$('#province').live('change',function(){
		var region_id = $(this).children('option:selected').val();
		var region_type = $(this).children('option:selected').attr('region_type');
		$('#city').css('display','block');
		$('#district').css('display','none');
		$.ajax({
			url:'__URL__/get_region',
			type:'post',
			dataType:'json',
			data:{region_type:region_type,region_id:region_id},
			beforeSuccess:function(){},
			success:function(msg){
				$('#city').html('').html(msg);
			}
		});
	});
	$('#city').live('change',function(){
		var region_id = $(this).children('option:selected').val();
		var region_type = $(this).children('option:selected').attr('region_type');
		$('#district').css('display','block');
		$.ajax({
			url:'__URL__/get_region',
			type:'post',
			dataType:'json',
			data:{region_type:region_type,region_id:region_id},
			beforeSuccess:function(){},
			success:function(msg){
				$('#district').html('').html(msg);
			}
		});
	});
});

/*show*/
$('#mod-retail-btn').click(function(){
	$('.address-wrap').show();
});
</script>




